package tests.jdl.databaseObjects;

import org.junit.Test;

import jdl.databaseObjects.DbType;
import junit.framework.Assert;

public class DbType_Test {
	@Test
	public void equals_referencesEqual() {
		DbTypeImpl instance = new DbTypeImpl("int");
		Assert.assertTrue(instance.equals(instance));
	}

	@Test
	public void equals_objIsNull() {
		DbTypeImpl instance = new DbTypeImpl("hi");
		Assert.assertFalse(instance.equals(null));
	}

	@Test
	public void equals_instanseTypeIsHello_objTypeIsHello() {
		DbTypeImpl instance = new DbTypeImpl("hello");
		DbTypeImpl obj = new DbTypeImpl("HeLlO");
		Assert.assertTrue(instance.equals(obj));
	}

	@Test
	public void equals_instanseTypeIsMsft_objTypeIsGoog() {
		DbTypeImpl instance = new DbTypeImpl("msft");
		DbTypeImpl obj = new DbTypeImpl("goog");
		Assert.assertFalse(instance.equals(obj));
	}

	class DbTypeImpl extends DbType {
		private String typeAsString;

		public DbTypeImpl(String typeAsString) {
			this.typeAsString = typeAsString;
		}

		@Override
		public String getTypeAsString() {
			return typeAsString;
		}
	}
}
